# -*- coding:utf-8 -*-
"""
@Author : 审心
@Time : 2023/10/24 14:12
"""
import glob
import unittest
from typing import List

from xlwings import Sheet

from autoTask.taobao.sycm.market_rank.item import FilterParam, ExcelAction, CacheAction
from common.utils import web_page_util


class WebTestCase(unittest.TestCase):
    """
    惰性求只
    """

    @property
    def p(self):
        if not hasattr(self, "_p"):
            self._p = web_page_util.create_page(is_refresh=False)
        return self._p

    @property
    def category_list(self):
        return ['漏勺', '汤勺', '全套勺铲', '砧板/菜板', '斩骨刀', '水果削皮器', '奶锅', '锅盖', '锅组套装',
                '蔬果刨丝器/瓜果刀', '菜刀', '全套厨房刀具', '小型燃气灶', '鱼鳞刨', '煎锅/平底锅', '厨房雕刻刀',
                '蒸格', '导热盘/解冻盘', '汤锅', '火锅炉', '烧水壶', '学生厨具套装', '压力锅/高压锅', '煎铲', '蒸锅',
                '炒锅', '砂锅/石锅', '其它', '油炸锅', '烹饪工具套装', '锅具可拆卸把手', '锅铲', '火锅', '汽锅',
                '炖锅/炖煲/汤煲', '多功能刀', '面包刀', '特殊用途刀', '冷冻调理刀', '木铲', '饭勺']

    def test_main1(self):
        from autoTask.taobao.sycm.market_rank.item import Main1
        from autoTask.taobao.enum import WebPlugin
        # Main1(self.category_list, "7天", self.p, WebPlugin.XSW, FilterParam(10, 10000, 3))()
        Main1(["炒锅", "蒸锅"], "7天", self.p, WebPlugin.XSW, FilterParam(10, 10000, 3))()

    def test_excel(self):
        from autoTask.taobao.sycm.market_rank.item import ExcelAction
        from autoTask.taobao.sycm.market_rank.item import FilterParam
        import xlwings as xw
        app = xw.App(visible=True, add_book=False)
        sht = app.books.open(ExcelAction.result_file_path()).sheets[0]
        from common.utils import ExcelUtil
        print(ExcelUtil.xw_get_last_used_column(sht, 1))

    def test_temp(self):
        import os
        ExcelAction.clear_excel()


if __name__ == '__main__':
    unittest.main()
